/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package beans;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author Emyzzz
 */
public class PostActionForm extends org.apache.struts.action.ActionForm {
    
    private String postTitle;

    private String postBody;
    private int threadid;
    private int memberid;
    private int postid;
   
    /**
     *
     */
    public PostActionForm() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        System.out.println("validate method");
        ActionErrors errors = new ActionErrors();
       if (getPostTitle() == null || getPostTitle().length() < 1) {
           System.out.println("name error");
            errors.add("EmptyTitle", new ActionMessage("postTitle"));
            // TODO: add 'error.name.required' key to your resources
        }
       if (getPostBody() == null || getPostBody().length() < 1) {
           System.out.println("body error");
            errors.add("EmptyBody", new ActionMessage("postBody"));
            // TODO: add 'error.name.required' key to your resources
        }
         return errors;
    }

    /**
     * @return the postTitle
     */
    public String getPostTitle() {
        
        return postTitle;
        
    }

    /**
     * @param postTitle the postTitle to set
     */
    public void setPostTitle(String postTitle) {
        this.postTitle = postTitle;
        System.out.println(postTitle);
    }

    /**
     * @return the postBody
     */
    public String getPostBody() {
        return postBody;
    }

    /**
     * @param postBody the postBody to set
     */
    public void setPostBody(String postBody) {
        System.out.println(postBody);
        this.postBody = postBody;
    }

    /**
     * @return the threadid
     */
    public int getThreadid() {
        return threadid;
    }

    /**
     * @param threadid the threadid to set
     */
    public void setThreadid(int threadid) {
        this.threadid = threadid;
        System.out.println(threadid);
    }

    /**
     * @return the memberid
     */
    public int getMemberid() {
        return memberid;
    }

    /**
     * @param memberid the memberid to set
     */
    public void setMemberid(int memberid) {
        this.memberid = memberid;
        System.out.println("form action"+memberid);
    }

    /**
     * @return the postid
     */
    public int getPostid() {
        return postid;
    }

    /**
     * @param postid the postid to set
     */
    public void setPostid(int postid) {
        this.postid = postid;
    }
}
